package com.example.invoke.extend.service;

import lombok.Data;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;

@Data
public class ServiceFactoryBean implements FactoryBean, InitializingBean {

    private String serviceId;
    private Class clazz;

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet---serviceId=" + serviceId);
    }

    @Override
    public Object getObject() {
        return ServiceRegistry.getService(serviceId);
    }

    @Override
    public Class<?> getObjectType() {
        return clazz;
    }
}
